/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-2-20
 * 
**/
package com.julewa.loading;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.julewa.ThreadValue;

public class ContentType {
	private Map<String, String> types = null; 
	private ThreadValue<String> contentType = new ThreadValue<String>();
	
	public ContentType(){ 
		types = new HashMap<String, String>();
		Set<String> keys = SystemUtils.getKeys();
		for(String k:keys){
			if(k.startsWith("response.type.")){
				types.put(k.substring("response.type".length()),SystemUtils.getProperty(k)); 
			}
		}
	}
	public String get(String suffix){
		suffix = types.get(suffix);
		if(suffix == null){
			return "text/html";
		}
		return suffix;
	}
	public String get(){
		//return contentType.get("text/html");
		return contentType.get();
	}
	public void set(String suffix){
		contentType.set(types.get(suffix));
	}
	
}
